package com.shuoyue.ycgk.ui.questionbank.note;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.QuestionNote;
import com.shuoyue.ycgk.entity.Rule;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;

public interface MyNoteContract {
    interface View extends BaseView {
        void setNote(QuestionNote note);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getMyNote(int questionId) {
            apply(model.getMyNote(questionId))
                    .subscribe(new ApiSubscriber<Optional<QuestionNote>>(mView, this,false) {
                        @Override
                        public void onNext(Optional<QuestionNote> lessonProcessOptional) {
                            super.onNext(lessonProcessOptional);
                            mView.setNote(lessonProcessOptional.getIncludeNull());
                        }

                    });
        }
    }

    class Model extends BaseModel {
        Observable<BaseResult<QuestionNote>> getMyNote(int questionId) {
            return RetrofitClient.getInstance().getApi().getMyQuestionNote(questionId,1);
        }
    }
}
